<?php $this->load->view('common/ck-bosspagehead'); ?>
<?php $this->load->view('common/ck-bossheader'); ?>
<article id="content">
    <div class="pgwrapper">
    <div class="w960 bg1 p15 bx_shw">
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td width="20%" style="border-right: 2px solid #e5e5e5;" valign="top">
		<?php $this->load->view('enterprises/leftnavCMS'); ?>
		</td>
		<td width="80%"><form enctype="multipart/form-data"
				action="/detailpage" onsubmit="return validateForm()" method="POST">
				<table width="100%" border="0" cellpadding="5" cellspacing="0"
					style="padding-left: 20px;">
					<tr>
						<td class="txt-blck">Select Store:</td>
						 <td><select id="code_store[]" name="code_store[]" multiple="multiple" style="width: 200px;" onchange="">
			                	<?php foreach ($allStoresArray as $temp){ ?>
								<option value="<?php echo $temp['store_id']; ?>">
								<?php echo $temp['store_name']; ?>
								</option>
								<?php } ?>		                	
			            	</select></td>
					</tr>
					<tr>
						<td class="txt-blck" width="30%">Coupon Title:</td>
						<td width="70%"><input type="text" value="" name="coupon_name"
							id="coupon_name" class="inputCMS"   />
						</td>
					</tr>
					<tr>
						<td class="txt-blck" width="30%">Coupon Code	:</td>
						<td width="70%"><input type="text" value="" name="coupon_code"
							id="coupon_code" class="inputCMS"   />
						</td>
					</tr>
					<tr>
						<td class="txt-blck">Coupon Status:</td>
						<td><select id="coupon_status" name="coupon_status">
								<option value="Yes">Yes</option>
								<option value="No">No</option>
						</select></td>
					</tr>
					<tr>
						<td class="txt-blck">Coupon Type:</td>
						<td><select id="coupon_type" name="coupon_type">
                                <option value="Offer">Offers</option>
								<option value="TopCpn">Top Coupons</option>
								<option value="FeaturedCpn">Featured Coupons</option>
								<option value="Cpn">Coupons</option>
						</select></td>
					</tr>
                    <tr>
						<td class="txt-blck">Coupon Bank:</td>
						<td><select id="coupon_bank" name="coupon_bank">
                                <option value="0">None</option>
                                <?php foreach($allBanksArray as $temp){ ?>
								<option value="<?php echo $temp['bank_id']; ?>"><?php echo $temp['bank_name']; ?></option>
                                <?php } ?>
						</select></td>
					</tr>
					<tr>
						<td class="txt-blck">Coupon Category:</td>
						<td><select id="coupon_cat" name="coupon_cat">
                                <option value="0">None</option>
                                <?php foreach($allCategoriesArray as $temp){ ?>
								<option value="<?php echo $temp['category_id']; ?>"><?php echo $temp['category_name']; ?></option>
                                <?php } ?>
						</select></td>
					</tr>
					<tr>
						<td class="txt-blck">Coupon Occasion:</td>
						<td><select id="coupon_occasion" name="coupon_occasion">
                                <option value="0">None</option>
                                <?php foreach($occasionArray as $temp){ ?>
								<option value="<?php echo $temp['occasion_id']; ?>"><?php echo $temp['occasion_name']; ?></option>
                                <?php } ?>
						</select></td>
					</tr>
					<tr>
						<td valign="top" class="txt-blck">Make Detail Page:</td>
						<td>
							<input type="checkbox" name="makedetail" id="makedetail" value="0"
									onclick="showExtra()" /> Yes
						</td>
					</tr>
					<tr>
						<td valign="top" class="txt-blck">Coupon Description:</td>
						<td><textarea style="width: 450px; height: 300px;" class="inputCMS"
								id="coupon_description" name="coupon_description"></textarea></td>
					</tr>
					<tr id="cpnUrl">
						<!-- <td class="txt-blck" width="30%">Coupon Url:</td><td width="70%"><input type="text" value="" name="coupon_url" id="coupon_url" class="inputCMS"   /></td> -->
						
					</tr>
					<tr id="desc1">
					<!-- <td valign="top" class="txt-blck">Coupon Description 2:</td><td><textarea style="width: 450px; height: 300px;" class="inputCMS" id="coupon_description_2" name="coupon_description_2"></textarea></td> -->
						
					</tr>
					<tr id="desc2">
					<!-- <td valign="top" class="txt-blck">Terms & Conditions:</td><td><textarea style="width: 450px; height: 300px;" class="inputCMS" id="terms_and_conditions" name="terms_and_conditions"></textarea></td> -->		
						
					</tr>
					<tr id="imgLarge">
						
					</tr>
					<tr>
						<td valign="top" class="txt-blck">Coupon Affliate URL:</td>
						<td>
							<div>
								<input type="checkbox" name="editURL" id="editURL" value="1"
									onclick="activeCAU();selectTrack();" /> Deep Link URL
							</div>
						<!-- 
							<div id="radioDiv" style="display:none;">
								<input type="radio" name="omg" id="omg" onclick="insertTrack(1)" /> OMG
								<input type="radio" name="tc" id="tc" onclick="insertTrack(2)" /> Trootrac
								<input type="radio" name="ty" id="ty" onclick="insertTrack(3)" /> Tyroo
							</div>
							 -->	
							<div id="affliateURLDiv">
                               
                                <input type="text" name="coupon_affilateurl" id="coupon_affilateurl" style="width: 320px" value=""	readonly />
							</div>
							
							<div id="utmsrc" style="display:none;">
								<input type="text" name="utmSource" id="utmSource" style="width: 400px" 
								onblur="if(this.value=='') this.value='Enter UTM Source Code Here..';" onfocus="if(this.value=='Enter UTM Source Code Here..')this.value='';" value="Enter UTM Source Code Here.." />
							</div>
							
						</td>
					</tr>
					<tr>
						<td valign="top" class="txt-blck">Coupon Start Date:</td>
						<td><input type="text" name="coupon_startdate" id="coupon_startdate" style="width: 100px"
							onfocus="javascript:NewCssCal('coupon_startdate','yyyymmdd','arrow',false,'24',false);"
							value=""
							readonly /> (yyyy/mm/dd)</td>
					</tr>
					<tr>
						<td valign="top" class="txt-blck">Coupon Expire Date:</td>
						<td><input type="text" name="coupon_expiredate" id="coupon_expiredate" style="width: 100px"
							onfocus="javascript:NewCssCal('coupon_expiredate','yyyymmdd','arrow',false,'24',false);"
							value=""
							readonly /> (yyyy/mm/dd)</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="submit" name="code_submit" value="Submit" /></td>
					</tr>
				</table>
			</form></td>
	</tr>
</table>
</div>
</div>
</article>
<div class="clr-both spacer-10">&nbsp;</div>
<?php $this->load->view('common/ck-bossfooter'); ?>
<script>

function validateForm(){
	var x = document.getElementById('coupon_name').value;
	if(x==""){
	alert("Coupon Title must be filled out.");
	return false;
	}
}
function showExtra(){
	var str = document.getElementById("coupon_name").value;
	str1 = str.toLowerCase();
	 str2 = str1.replace(/[^a-zA-Z 0-9]+/g,'');
	str3 = str2.replace(/\s{1,}/g,"-");
	
	if(document.getElementById("makedetail").checked){
		document.getElementById("cpnUrl").innerHTML='<td class="txt-blck" width="30%">Coupon Url:</td><td width="70%"><input type="text" value="'+str3+'" name="coupon_url" id="coupon_url" class="inputCMS"   /></td>';
		document.getElementById("desc1").innerHTML='<td valign="top" class="txt-blck">Coupon Description 2:</td><td><textarea style="width: 450px; height: 300px;" class="inputCMS" id="coupon_description_2" name="coupon_description_2"></textarea></td>';
		document.getElementById("desc2").innerHTML='<td valign="top" class="txt-blck">Terms & Conditions:</td><td><textarea style="width: 450px; height: 300px;" class="inputCMS" id="terms_and_conditions" name="terms_and_conditions"></textarea></td>';
		document.getElementById("imgLarge").innerHTML='<td class="txt-blck" width="30%">Coupon Banner:</td><td width="70%"><input type="file" value="" name="coupon_banner" id="coupon_banner" /></td>';
	}else{
		document.getElementById("cpnUrl").innerHTML='';
		document.getElementById("desc1").innerHTML='';
		document.getElementById("desc2").innerHTML='';
		document.getElementById("imgLarge").innerHTML='';
	}
}
</script>
